<% content_for :content do %>

  <!-- widget grid -->
  <section id="widget-grid" class="">

    <div class="row">
      <div class="col-sm-12">
        <div class="well">

          <%= simple_form_for :message_warnning, url: admin_message_warnnings_path, :defaults => { :input_html => { :class => "form-control" } }, method: 'get', html: {class: "form-inline" } do |f| %>
            <label>信息类型</label>
            <%= f.input_field :warnning_code, collection: [["全部","all"], *MessageWarnning::MSG_INFO.collect{|k,v| [v,k] }, ["发送失败", "error"]], selected: ( params[:message_warnning][:warnning_code].nil? ? 'all' : params[:message_warnning][:warnning_code]) %>
            &nbsp;&nbsp;
            <label>手机号</label>
            <%= f.input_field :mobile_number, collection:  MessageWarnning.select(:mobile_number).uniq.map(&:mobile_number), selected: params[:message_warnning][:mobile_number], prompt: '请选择手机号' %>
            &nbsp;&nbsp;
            <label>创建日期</label>
            <div class="form-group string">
              <%= f.text_field :start_date, class: 'form-control datepicker', "data-dateformat" => "yy-mm-dd", value: params[:message_warnning][:start_date], placeholder: "From" %>
            </div>
            <div class="form-group string">
              <%= f.text_field :end_date, class: 'form-control datepicker', "data-dateformat" => "yy-mm-dd", value: params[:message_warnning][:end_date], placeholder: "To" %>
            </div>
            <%= f.submit "搜索", :class => "btn btn-default"%>
          <% end %>

        </div> <!-- end well div -->

      </div>
    </div>
    
    <!-- row -->
    <div class="row">
      <!-- NEW WIDGET START -->
      <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        
        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget jarviswidget-color-darken" id="wid-id-0" data-widget-editbutton="false" data-widget-colorbutton="false" data-widget-deletebutton="false">

          <!-- widget options:
          usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

          data-widget-colorbutton="false"
          data-widget-editbutton="false"
          data-widget-togglebutton="false"
          data-widget-deletebutton="false"
          data-widget-fullscreenbutton="false"
          data-widget-custombutton="false"
          data-widget-collapsed="true"
          data-widget-sortable="false"

          -->
          <header>
            <span class="widget-icon"> <i class="fa fa-table"></i> </span>
            <h2>短信列表</h2>
          </header>

          <!-- widget div-->
          <div>

            <!-- widget edit box -->
            <div class="jarviswidget-editbox">
              <!-- This area used as dropdown edit box -->
            </div>
            <!-- end widget edit box -->
            
            <!-- widget content -->
            <div class="widget-body no-padding">

              <div class="alert alert-info no-margin">
                <span class="">
                  <i class="fa-fw fa fa-info"></i>共有<%= @message_warnnings.total_count %>条记录
                </span>
                <span class="col-md-offset">
                  <a class="btn btn-default btn-sm" href="<%= admin_message_warnnings_path(format: :csv) %>">导出为CSV</a>
                </span>
              </div>

              <table class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>手机</th>
                    <th>代码</th>
                    <th>信息</th>
                    <th>创建时间</th>
                    <th>短信内容</th>
                  </tr>
                </thead>
                <tbody>
                <% @message_warnnings.each do |message_warnning| %>
                  <tr id='message_warnning-<%= message_warnning.id %>'>
                    <td>
                      <%= message_warnning.mobile_number %>
                    </td>
                    <td>
                      <%= message_warnning.warnning_code %>
                    </td>
                    <td>
                      <%= message_warnning.display_name %> 
                    </td>
                    <td>
                      <%= message_warnning.created_at.stamp("2013-03-12 22:02:01") %>
                    </td>
                    <td>
                      <%= message_warnning.message %>
                    </td>
                  </tr>
                <% end %>
                </tbody>
              </table>

              <div class="dt-row dt-bottom-row"><div class="row"><div class="col-sm-6"><div class="dataTables_info" id="datatable_fixed_column_info"></div></div><div class="col-sm-6 text-right"><%= paginate @message_warnnings %></div></div></div>

            </div>
            <!-- end widget content -->

          </div>
          <!-- end widget div -->

        </div>
        <!-- end widget -->
  
      </article>
      <!-- WIDGET END -->

    </div>
  
    <!-- end row -->


    <!-- row -->
    <div class="row">
      <!-- NEW WIDGET START -->
      <div class="col-xs-12 col-sm-4 col-md-5 col-lg-5 sortable-grid ui-sortable">
        
        <div class="well">

          <h4>常用汇总</h4>
          <ul>
            <% MessageWarnning::MSG_INFO.each do |kcode,vinfo| %>
            <li>
              <%= vinfo %> <%= MessageWarnning.where('warnning_code = ?',kcode).count %>
            </li>
            <% end %>
          </ul>

        </div>
      </div>
      <!-- WIDGET END -->

      <!-- NEW WIDGET START -->
      <article class="col-xs-12 col-sm-8 col-md-7 col-lg-7 sortable-grid ui-sortable">
        
        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget jarviswidget-color-darken" id="wid-id-2" data-widget-editbutton="false" data-widget-colorbutton="false" data-widget-deletebutton="false">
          <!-- widget options:
          usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

          data-widget-colorbutton="false"
          data-widget-editbutton="false"
          data-widget-togglebutton="false"
          data-widget-deletebutton="false"
          data-widget-fullscreenbutton="false"
          data-widget-custombutton="false"
          data-widget-collapsed="true"
          data-widget-sortable="false"

          -->
          <header>
            <span class="widget-icon"> <i class="fa fa-bar-chart-o"></i> </span>
            <h2> <%= @chart_attrs[:title] %> </h2>
          </header>

          <!-- widget div-->
          <div>

            <!-- widget edit box -->
            <div class="jarviswidget-editbox">
              <!-- This area used as dropdown edit box -->
            </div>
            <!-- end widget edit box -->
            
            <!-- widget content -->
            <div class="widget-body no-padding">

              <%= render :partial => "charts/chart",:locals => {:chart_attrs => @chart_attrs,:page_id => ''} if @chart_attrs %>

            </div>
            <!-- end widget content -->

          </div>
          <!-- end widget div -->

        </div>
        <!-- end widget -->
  
      </article>
      <!-- WIDGET END -->

    </div>
  
    <!-- end row -->

  </section>
  <!-- end widget grid -->
<% end %>